Memory leak in xc_linux_save, and uninitialised var
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 11 Aug 2005 22:12:11 +0000 (22:12 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 11 Aug 2005 22:12:11 +0000 (22:12 +0000)
in secpol_tool.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
tools/libxc/xc_linux_save.c
tools/security/secpol_tool.c

index 930002f68495bc5999b2c0deb28647f7d2503466..c2a6af5f1358247fd0a39a826e42e790e354adf2 100644 (file)
@@ -429,7 +429,7 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom)
        - that should be sent this iteration (unless later marked as skip); 
        - to skip this iteration because already dirty;
        - to fixup by sending at the end if not already resent; */
-    unsigned long *to_send, *to_skip, *to_fix;
+    unsigned long *to_send = NULL, *to_skip = NULL, *to_fix = NULL;
     
     xc_shadow_control_stats_t stats;
 
@@ -1054,6 +1054,18 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom)
     if (pfn_type != NULL) 
         free(pfn_type);
 
+    if (pfn_batch != NULL)
+        free(pfn_batch);
+
+    if (to_send != NULL)
+        free(to_send);
+
+    if (to_fix != NULL)
+        free(to_fix);
+
+    if (to_skip != NULL)
+       free(to_skip);
+
     DPRINTF("Save exit rc=%d\n",rc);
     return !!rc;
 }
index 6c1e5f0fc860a31788d4f2e5604ca679824587cf..f7a084eb77ef75195bcbd34b3193fd1c6cffaef4 100644 (file)
@@ -612,7 +612,7 @@ void usage(char *progname)
 int main(int argc, char **argv)
 {
 
-    int acm_cmd_fd, ret;
+    int acm_cmd_fd, ret = 0;
 
     if (argc < 2)
         usage(argv[0]);